package com.kaili.basic.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

import javax.annotation.PostConstruct;

/**
 * @Desc: session缓存配置
 * @author:zhengs
 * @Time: 19-1-24 下午4:00
 * @Copyright: ©  杭州凯立通信有限公司 版权所有
 * @Warning: 本内容仅限于公司内部传阅,禁止外泄或用于其它商业目的
 */
@EnableRedisHttpSession
public class HttpSessionConfig {
    /**
    * 缓存超时时间设置,默认30分钟,单位为秒
    */
    @Value("${server.session.timeout}")
    private Integer maxInactiveIntervalInMinutes = 60 * 30;

    @Autowired
    private RedisOperationsSessionRepository sessionRepository;

    @PostConstruct
    private void afterPropertiesSet(){
        sessionRepository.setDefaultMaxInactiveInterval(maxInactiveIntervalInMinutes);
    }
}
